package com.biao.java8.starem_test;

import com.biao.java8.demo.pojo.Employee;

import java.util.ArrayList;
import java.util.List;

public class Test05_anyMatch_allMatch {
    public static void main(String[] args) {
        List<Employee> listEmployee = new ArrayList<>();
        listEmployee.add(new Employee("abiu", 18, 8000d));
        listEmployee.add(new Employee("二狗", 24, 16000d));
        listEmployee.add(new Employee("黑狗哥", 27, 24000d));

        // match 用法
        // 查集合元素中是否有包含 abiu 名字的
        boolean anyMatch = listEmployee.stream().anyMatch((a) -> "abiu".equals(a.getName()));
        // 集合中所有元素都包含 abiu 名字的
        boolean allMatch = listEmployee.stream().allMatch((a) -> "abiu".equals(a.getName()));
        System.out.println("match: --------------------------------");
        System.out.println(anyMatch);
        System.out.println(allMatch);
    }
}
